package com.boat.sample.ddd.application.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import com.boat.sample.ddd.domain.system.event.UserRegistered;
import com.boat.sample.ddd.domain.system.service.UserService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class UserRegisteredListener {
	@Autowired
	UserService userService;

	@EventListener
	public void listen(UserRegistered event) {
		log.info("收到UserRegistered。 userName={}", event.getUser().getUserName());
		String content = event.getUser().getUserName() + "注册成功";
		userService.createUserLog(event.getUser().getUserName(), content);
	}
}
